// maindlg.h : interface of the CMediaListDlg class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MEDIALISTDLG_H__CCDDE62F_EDDB_4665_B6D3_91CBB5636920__INCLUDED_)
#define AFX_MEDIALISTDLG_H__CCDDE62F_EDDB_4665_B6D3_91CBB5636920__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include <atlframe.h> // for CDialogResize<>
#include <atlctrls.h> // for member controls
#include "FCListviewCtrl.h"
#include "FileTools.h"
#include "Contosrv.h"
#include "constdef.h"
#include "Config.h"

class CMediaListDlg : public CDialogImpl<CMediaListDlg>, public CUpdateUI<CMediaListDlg>, public CDialogResize<CMediaListDlg>
{
public:
	CMediaListDlg(CContosrv* aCon,CConfig* config) { m_Conn = aCon;  m_Config = config;}; 

	enum { IDD = IDD_MEDIALISTDLG };

	BEGIN_UPDATE_UI_MAP(CMediaListDlg)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(CMediaListDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
		COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
		COMMAND_ID_HANDLER(ID_BACK, OnCloseCmd)
		COMMAND_ID_HANDLER(ID_PLAY, OnPlayCmd)
		NOTIFY_CODE_HANDLER(LVN_ITEMCHANGED, OnItemChanged)
		NOTIFY_CODE_HANDLER(NM_RETURN, OnListClick)
		NOTIFY_CODE_HANDLER(NM_DBLCLK, OnListClick)

		CHAIN_MSG_MAP(CDialogResize<CMediaListDlg>) 
	END_MSG_MAP()

	BEGIN_DLGRESIZE_MAP(CMediaListDlg) // Flags: DLSZ_SIZE_X or DLSZ_MOVE_X, DLSZ_SIZE_Y  or DLSZ_MOVE_X, DLSZ_REPAINT
		DLGRESIZE_CONTROL(IDC_MEDIALIST,     DLSZ_SIZE_X | DLSZ_SIZE_Y)
	END_DLGRESIZE_MAP()

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

	LRESULT OnPlayCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

	LRESULT OnItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
	LRESULT OnListClick(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

	void CloseDialog(int nVal);

protected:
	int LoadMediaList();
	void DoPlayMedia(TCHAR* name);

	void DownLoadMediaAndPlay();

private:
	HMENU m_hMenu;
	CFCListViewCtrl   m_idcList;
	CImageList		m_imgList;
	CSimpleArray<TPath> m_mediaArray;

	CContosrv* m_Conn;
	CConfig* m_Config;
};


/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MEDIALISTDLG_H__CCDDE62F_EDDB_4665_B6D3_91CBB5636920__INCLUDED_)
